<#--页面是否为读的模式 默认为编辑模式-->
<#assign readMode__=(opState!"update")=="read" />
<#assign nToStrMap={"1":"one","2":"two","3":"three","4":"four","5":"five","6":"six","7":"seven","8":"eight","9":"nine","10":"ten","11":"eleven","12":"twelve","13":"thirteen","14":"fourteen","15":"fifteen","16":"sixteen"} />
<#assign hasSoMode=(soState!true)==false />
<#--数字字符串转成英文数字-->
<#function coverToStr tmp="">
    <#if tmp=="">
        <#return "">
    </#if>
    <#assign cover=nToStrMap[tmp]!"" />
    <#return (cover=="")?string(tmp,cover)/>
</#function>
<#function attr n v="">
    <#if v=="">
        <#return ""/>
    </#if>
    <#return " "+n+"=\""+v+"\" " />
</#function>
<#--<#macro ifValue name="" value=""><#if value!=""><#if name!="">${name}="${value}"<#else>${value}</#if></#if></#macro>-->
<#macro input id="" class="" width="" name="" value="" readonly=false onclick="" dataType="" placeholder="">
    <#assign newWidth=coverToStr(width) />
<#--页面只读模式-->
    <#if readMode__>
        <@label aligned="left" width=width value=value goods_ele_selector=id valueLabel=true ></@label>
    <#else >
    <#--页面编辑模式-->
    <div class="<#if newWidth!=""> ${newWidth} wide </#if>column <#if class!=""> ${class}</#if> field input-div<#if readonly> disabled</#if>">
        <input <#if id!="">id="${id}"</#if>  <#if onclick!="">onclick="${onclick}"</#if>
               class="ui input" type="text"
               <#if name!="">name="${name}"</#if><#if value!="">value="${value}"</#if><#if dataType!="">
               data-type="${dataType}"</#if><#if placeholder!="">placeholder="${placeholder}"</#if>/>
    </div>
    </#if>
</#macro>

<#macro label class="" width="" value="" aligned="right" dropdown_ref="" goods_ele_selector="" valueLabel=false required=false >
    <#assign newWidth=coverToStr(width) />
<div
        class="<#if newWidth!="">${newWidth} wide </#if>column ui basic label ${aligned} aligned<#if required> required</#if><#if class!=""> ${class}</#if>"
        title="<#if valueLabel>${value}</#if>" <#if dropdown_ref!="">dropdown_ref=${dropdown_ref}</#if>
    <#if goods_ele_selector!="">goods_ele_selector=${goods_ele_selector}
    </#if>
        style="background-color:
            <#if valueLabel>inherit<#else>#e3ecf3</#if>;overflow:hidden;text-overflow:clip;white-space:nowrap;">${value}</div></#macro>
<#--
无论value为隐藏之还是真实值，semantic ui的下拉框都会将其转换成真实值(数据本地化后）
id:下拉框id
showId:存储展示值数据的隐藏input的id
class:扩展class
width:宽度 wide
value:真实值
showName:存储展示数据的隐藏input的name
showValue:存储展示数据的隐藏input的值
asValue:存储展示数据的隐藏input的值是否与下拉框真实值一致，如果该值为true则忽略showValue
dropdown_ref:用于只读页面中显示对应下拉框的显示值
name_selector:用于只读页面中显示商品信息
-->
<#macro dropdown id="" showId="" class="" width="" name="" value="" showName="" showValue="" asValue=false readonly=false placeholder="" >
<#--页面只读模式-->
    <#if readMode__>
        <@label aligned="left" width=width value=((showValue=="")?string(value,showValue)) dropdown_ref=((showValue=="" && value != "" && !asValue)?string(name, "")) goods_ele_selector=id valueLabel=true ></@label>
    <#else>
        <#assign newWidth=coverToStr(width) />
        <#assign newWidth=((newWidth=="")?string("",newWidth+" wide")) />
        <#assign readonlyStr=(readonly?string(" disabled","")) />
        <#assign showText=(showValue=="")?string(value,showValue)/>
    <div class="ui fluid search selection dropdown ${newWidth} column ${class} field${readonlyStr}">
        <input type="hidden" ${attr("id",id)} ${attr("name",name)} ${attr("value",value)} pk>
        <input type="hidden" ${attr("id",showId)} ${attr("name",showName)} ${attr("value",showValue)}
               show>
        <i class="dropdown icon"></i>
        <input type="text" class="search" tabindex="0">

        <div class="${((showText=="")?string("default ",""))}text">${((showText=="")?string(placeholder,showText))}</div>
        <div class="menu" tabindex="-1">
        <#-- <div class="item" data-value="" data-text="请选择">请选择</div>-->
        </div>
    </div>
    </#if>
</#macro>


<!--专门用于占位置的标签-->
<#macro blankPlaceholder width="" id="">
    <#assign newWidth=coverToStr(width) />
<div class="<#if newWidth!="">${newWidth} wide </#if>column ui basic label right aligned"
     style="border:none;text-align:left;" id="${id}"></div>
</#macro>
